home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / scsiDiskBoot / sun3.md / RCS / dev.c,v < prev    next >
Encoding:
Text File  |  1989-06-08  |  7.2 KB  |  361 lines

  1. head     1.6;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    mendel:1.6; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.6
  10. date     89.01.06.08.13.48;  author brent;  state Exp;
  11. branches ;
  12. next     1.5;
  13.  
  14. 1.5
  15. date     87.05.27.14.31.55;  author brent;  state Exp;
  16. branches ;
  17. next     1.4;
  18.  
  19. 1.4
  20. date     87.05.11.11.13.45;  author brent;  state Exp;
  21. branches ;
  22. next     1.3;
  23.  
  24. 1.3
  25. date     87.05.08.17.43.25;  author brent;  state Exp;
  26. branches ;
  27. next     1.2;
  28.  
  29. 1.2
  30. date     86.07.21.09.33.10;  author brent;  state Exp;
  31. branches ;
  32. next     1.1;
  33.  
  34. 1.1
  35. date     86.07.17.13.13.26;  author brent;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39.  
  40. desc
  41. @General device support
  42. @
  43.  
  44.  
  45. 1.6
  46. log
  47. @New include files and constants due to source reorganization
  48. @
  49. text
  50. @/*
  51.  * dev.c
  52.  *    Excerpts from the dev module in the kernel.
  53.  *
  54.  * Copyright 1986 Regents of the University of California
  55.  * All rights reserved.
  56.  */
  57.  
  58. #ifndef lint
  59. static char rcsid[] = "$Header: dev.c,v 1.5 87/05/27 14:31:55 brent Exp $ SPRITE (Berkeley)";
  60. #endif not lint
  61.  
  62.  
  63. #include "sprite.h"
  64. #include "dev.h"
  65. #include "devInt.h"
  66. #include "devMultibus.h"
  67. #include "vmSunConst.h"
  68.  
  69.  
  70. /*
  71.  *----------------------------------------------------------------------
  72.  *
  73.  * Dev_Config --
  74.  *
  75.  *    Call the initialization routines for various controllers and
  76.  *    devices based on configuration tables.  This should be called
  77.  *    after the regular memory allocater is set up so the drivers
  78.  *    can use it to configure themselves.
  79.  *
  80.  * Results:
  81.  *    None.
  82.  *
  83.  * Side effects:
  84.  *    Call the controller and device initialization routines.
  85.  *
  86.  *----------------------------------------------------------------------
  87.  */
  88. void
  89. Dev_Config()
  90. {
  91.     register int index;
  92.     register int status;
  93.     register int machType = Mach_GetMachineType();
  94.     register Boolean mapItIn = TRUE;
  95.     register int memoryType;
  96.  
  97.     for (index = 0 ; index < devNumConfigCntrlrs ; index++) {
  98.     register DevConfigController *cntrlrPtr;
  99.     cntrlrPtr = &devCntrlr[index];
  100.     /*
  101.      * Multibus device addresses are relative to the base of
  102.      * Multibus memory as it is mapped into the kernel.  Have
  103.      * to add the base address here.
  104.      */
  105.     if (machType == SYS_SUN_2_120) {
  106.         if (cntrlrPtr->space != DEV_MULTIBUS) {
  107.         /*
  108.          * Mapping VME addresses into a Multibus machine messes up.
  109.          */
  110.         continue;
  111.         } else {
  112.         cntrlrPtr->address += DEV_MULTIBUS_BASE;
  113.         mapItIn = FALSE;
  114.         }
  115.     } else {
  116.         /*
  117.          * Handle the various VME spaces.  Not all of them, this is
  118.          * optimized for space so only devices that appear in devConfig.c
  119.          * will be handled.
  120.          */
  121.         switch(cntrlrPtr->space) {
  122.         /*
  123.          * We have to relocate the controller address to the
  124.          * true VME PHYSICAL address that the Sun MMU uses for
  125.          * the different types of VME spaces.
  126.          */
  127.         case DEV_VME_D16A16:
  128.             /*
  129.              * The high 64K of the VME address range is stolen for the
  130.              * 16 bit address subset.
  131.              */
  132.             cntrlrPtr->address += 0xFFFF0000;
  133.             break;
  134.         case DEV_VME_D16A24:
  135.             /*
  136.              * The high 16 Megabytes of the VME address range is stolen
  137.              * for the 24 bit address subset.
  138.              */
  139.             cntrlrPtr->address += 0xFF000000;
  140.             break;
  141.             /*
  142.              * The addresses for the full 32 bit VME bus are ok.
  143.              */
  144.         }
  145.     }
  146.     /*
  147.      * To save space, the memoryType is set to 2 always.  This handles
  148.      * the normal controllers using the 16 bit data bus.
  149.      */
  150. #ifdef notdef
  151.     switch(cntrlrPtr->space) {
  152.         case DEV_MULTIBUS:
  153.         memoryType = 2;
  154.         break;
  155.         case DEV_VME_D16A16:
  156.         case DEV_VME_D16A24:
  157.         case DEV_VME_D16A32:
  158.         if (machType == SYS_SUN_2_50) {
  159.             if (cntrlrPtr->address >= 0xFF800000) {
  160.             memoryType = 3;
  161.             } else {
  162.             memoryType = 2;
  163.             }
  164.         } else {
  165.             memoryType = 2;
  166.         }
  167.         break;
  168.         case DEV_MULTIBUS_IO:
  169.         case DEV_VME_D32A16:
  170.         case DEV_VME_D32A24:
  171.         case DEV_VME_D32A32:
  172.         memoryType = 3;
  173.         break;
  174.     }
  175. #endif
  176.     memoryType = 2;
  177.     if (mapItIn) {
  178.         cntrlrPtr->address =
  179.         (int)Vm_MapInDevice(cntrlrPtr->address, memoryType);
  180.     }
  181.     if (cntrlrPtr->address != NIL) {
  182.         int exists = (*cntrlrPtr->initProc)(cntrlrPtr);
  183. #ifndef NO_PRINTF
  184.         if (exists) {
  185.         Sys_Printf("%s-%d at kernel address %x\n", cntrlrPtr->name,
  186.                   cntrlrPtr->controllerID, cntrlrPtr->address);
  187.         }
  188. #endif
  189.     }
  190.     }
  191.  
  192.     for (index = 0 ; index < devNumConfigDevices ; index++) {
  193.     register DevConfigDevice *devPtr;
  194.     devPtr = &devDevice[index];
  195. #ifndef NO_PRINTF
  196.     Sys_Printf("Dev %d-%d flags %d ... ", devPtr->controllerID,
  197.             devPtr->slaveID, devPtr->flags);
  198. #endif
  199.     status = (*devPtr->initProc)(devPtr);
  200. #ifndef NO_PRINTF
  201.     Sys_Printf("<%x>\n", status);
  202. #endif
  203.     }
  204. }
  205.  
  206. /*
  207.  * Private storage for Dev_IOAlloc.  DMA memory is alreay mapped
  208.  * for us by the PROM so we just allocate from it.
  209.  */
  210. static Address    ioMemEnd = (Address)VMMACH_DMA_START_ADDR;
  211.  
  212. /*
  213.  * ----------------------------------------------------------------------------
  214.  *
  215.  * Dev_IOAlloc --
  216.  *
  217.  *     Allocate a block of memory of the given size from the
  218.  *    device memory space.  This returns
  219.  *    block aligned buffers so mapping works later.
  220.  *
  221.  * Results:
  222.  *     A pointer to the allocated memory.
  223.  *
  224.  * Side effects:
  225.  *     ioMemEnd is incremented in page size chunks.
  226.  *
  227.  * ----------------------------------------------------------------------------
  228.  */
  229.  
  230. Address
  231. Dev_IOAlloc(numBytes)
  232.     register int numBytes;
  233. {
  234.     register Address    addr;
  235.  
  236.     addr =  ioMemEnd;
  237.  
  238.     ioMemEnd += (numBytes + VMMACH_PAGE_SIZE) & ~(VMMACH_PAGE_SIZE-1);
  239.  
  240.     return(addr);
  241. }
  242. @
  243.  
  244.  
  245. 1.5
  246. log
  247. @was still using DEV_MULTIBUS, not VM_DMA_START_ADDR, oops.
  248. @
  249. text
  250. @d10 1
  251. a10 1
  252. static char rcsid[] = "$Header: dev.c,v 1.4 87/05/11 11:13:45 brent Exp $ SPRITE (Berkeley)";
  253. d17 1
  254. a17 1
  255. #include "multibus.h"
  256. d63 1
  257. a63 1
  258.         cntrlrPtr->address += MULTIBUS_BASE;
  259. d161 1
  260. a161 1
  261. static Address    ioMemEnd = (Address)VM_DMA_START_ADDR;
  262. d189 1
  263. a189 1
  264.     ioMemEnd += (numBytes + VM_PAGE_SIZE) & ~(VM_PAGE_SIZE-1);
  265. @
  266.  
  267.  
  268. 1.4
  269. log
  270. @Trimmed down version that handles MULTIBUS, VME_D16A16 and VME_D16A24
  271. type controllers.
  272. @
  273. text
  274. @d10 1
  275. a10 1
  276. static char rcsid[] = "$Header: dev.c,v 1.3 87/05/08 17:43:25 brent Exp $ SPRITE (Berkeley)";
  277. d158 1
  278. a158 1
  279.  * Private storage for Dev_IOAlloc.  Multibus memory is alreay mapped
  280. d161 1
  281. a161 1
  282. static Address    ioMemEnd = (Address)MULTIBUS_BASE;
  283. d169 1
  284. a169 1
  285.  *    device memory space (multibus memory).  This returns
  286. @
  287.  
  288.  
  289. 1.3
  290. log
  291. @Fleshed out Dev_Config so it can handle different VME/Multibus configs
  292. @
  293. text
  294. @d10 1
  295. a10 1
  296. static char rcsid[] = "$Header: dev.c,v 1.2 86/07/21 09:33:10 brent Exp $ SPRITE (Berkeley)";
  297. d68 3
  298. a70 1
  299.          * Handle the various VME spaces.
  300. a72 2
  301.         case DEV_MULTIBUS:
  302.             continue;
  303. a77 1
  304.         case DEV_VME_D32A16:
  305. a84 1
  306.         case DEV_VME_D32A24:
  307. a94 3
  308.         case DEV_VME_D16A32:
  309.         case DEV_VME_D32A32:
  310.             break;
  311. d97 5
  312. d126 2
  313. d134 1
  314. a134 1
  315. #ifndef NO_PRINTFS
  316. d146 1
  317. d149 1
  318. d151 1
  319. d153 1
  320. @
  321.  
  322.  
  323. 1.2
  324. log
  325. @Moved Dev_IOAlloc here
  326. @
  327. text
  328. @d10 1
  329. a10 1
  330. static char rcsid[] = "$Header: dev.c,v 1.1 86/07/17 13:13:26 brent Exp $ SPRITE (Berkeley)";
  331. d43 4
  332. d54 1
  333. a54 2
  334.      * to add the base address here.  SHOULD CHECK FOR DIFFERENT
  335.      * MACHINE TYPES AS vme WILL BE DIFFERENT.
  336. d56 45
  337. a100 2
  338.     if (cntrlrPtr->address != 0) {
  339.         cntrlrPtr->address += MULTIBUS_BASE;
  340. d102 37
  341. a138 1
  342.     (void)(*cntrlrPtr->initProc)(cntrlrPtr);
  343. d144 4
  344. a147 1
  345.     (void)(*devPtr->initProc)(devPtr);
  346. @
  347.  
  348.  
  349. 1.1
  350. log
  351. @Initial revision
  352. @
  353. text
  354. @d10 1
  355. a10 1
  356. static char rcsid[] = "$Header: proto.c,v 1.4 86/03/20 14:00:11 andrew Exp $ SPRITE (Berkeley)";
  357. d15 1
  358. d18 1
  359. d64 37
  360. @
  361.